package tiled.simple.gwt.client;

import java.util.ArrayList;
import java.util.Iterator;

import org.jbox2d.dynamics.World;

import com.google.gwt.canvas.dom.client.Context2d;

import tiled.simple.core.MapObject;
import tiled.simple.core.TMXObjectsProvider;

public class MapObjectsProvider implements TMXObjectsProvider{
	private World world;
	
	public MapObjectsProvider(World world) {
		this.world=world;
	}

	private ArrayList<Entity> entities = new ArrayList<Entity>();
	
	public void object(MapObject mapObject) {
		if(mapObject.getType().equalsIgnoreCase("RedBall")){
			RedBall redBall=new RedBall(world,mapObject);
			entities.add(redBall);
		}
	}
	
	public void render(Context2d context){
		Iterator<Entity> itr=entities.iterator();
		while (itr.hasNext()) {
			Entity entity=itr.next();
			
			entity.render(context);
		}
	}

}
